<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="../common.jsp" %>
<div class="contentcontainer">
    <div class="headings altheading">
        <h2><fmt:message key="view.role.add" /></h2>
    </div>		
	<div class="contentbox">
      	<form id="form_role_add" action="${_ctx}/user/role-add.action" method="POST">
		<fieldset>
       		<p>
				<label for="textfield"><strong><fmt:message key="view.role.code" />:</strong> <span class="smltxt">(最多20个字母)</span></label>
                <input type="text"  name="role.code" id="code"  class="inputbox" /> <br />
			</p>
        	<p>
                 <label for="textfield"><strong><fmt:message key="view.role.name" />:</strong><span class="smltxt">(最多50个字符)</span></label>
                 <input type="text"  name="role.name"  class="inputbox"/> <br />
            </p>                
  			<input type="submit" class="btn" value="<fmt:message key="view.add" />"/>
  		</fieldset>
		</form>         
	</div>	

</div>

	<script type="text/javascript">
		$(document).ready(function() {
			rightside.modalForm("form_role_add");
			
			$("#form_role_add").validate({
				rules: {
					"role.code": {
						required: true,
						minlength: 2,
						remote: {
							url: "${_ctx}/user/role-form-check.action?type=code",
							data: {
								code : function() { return $("#code").val();}
							}
						}
					},
					"role.name": {
						required: true,
						minlength: 5
					}
				},
				messages: {
					"role.code": {
						required: "Please enter a username",
						minlength: "Your username must consist of at least 2 characters",
						remote: "编号重复"
					},
					"role.name": {
						required: "Please provide a password",
						minlength: "Your password must be at least 5 characters long"
					}
				}
			});			
			
		});
	</script>
